package com.asistencia.businness;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.asistencia.dao.interfaces.ProfessorDao;
import com.asistencia.domain.Professor;

@Service
public class ProfessorBusiness {

	@Autowired
	private ProfessorDao professorDao;

	@Autowired
	private Professor professor;

	public Professor loginProfessor(String username, String password) {
		try {
			professor = professorDao.login(username, password);
			return professor;
		}
		catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public Professor getById(Integer idProfessor) {
		try {
			professor = professorDao.getById(idProfessor);
			return professor;
		}
		catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		}

	}

	public List<Professor> listAll() {
		try {
			professorDao.listAll();
			List<Professor> lstAll = professorDao.listAll();
			return lstAll;
		}
		catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		}
		catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public List<Professor> listByName(String name) {
		try {
			professorDao.listByName(name);
			List<Professor> lstPro = professorDao.listByName(name);
			return lstPro;
		}
		catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		}
		catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public List<Professor> listByCareer(Integer idCareer) {
		try {
			professorDao.listByCareer(idCareer);
			List<Professor> lstPro = professorDao.listByCareer(idCareer);
			return lstPro;
		}
		catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		}
		catch (Exception e) {
			e.printStackTrace();
			return null;
		}

	}

}
